﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Card.Manager
{
    public partial class OrderDetail : BasePage
    {
        #region
        /// <summary>
        /// 订单编号
        /// </summary>
        public string OrderID
        {
            get
            {
                if (!string.IsNullOrEmpty(Request.QueryString["oid"]))
                {
                    return Request.QueryString["oid"];
                }
                return string.Empty;
            }
        }

        public Entity.Order Order = null;
        public Entity.Users Users = null;
        #endregion

        #region
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.DoInit();
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            this.Order = BLL.OrderManager.GetEntity(this.OrderID, this.Passport);
            if (this.Order != null)
            {
                this.Order.OrderStatusCode = this.dropStatus.SelectedValue;
                BLL.OrderManager.Update(this.Order, null);
                Response.Redirect(string.Format("OrderDetail.aspx?oid={0}",this.OrderID));                
            }

        }

        protected void btnBack_Click(object sender, EventArgs e)
        {
            Response.Redirect("OrderManager.aspx");
        }
        #endregion

        #region
        private void DoInit()
        {
            this.Order = BLL.OrderManager.GetEntity(this.OrderID, this.Passport);
            if (this.Order != null)
            {
                Common.CardWebUtility.BindOrderStatus(this.dropStatus, false);
                Card.Utility.ControlUtility.SelectItemByValue(this.dropStatus, Order.OrderStatusCode);
                this.Users = BLL.UsersManager.GetEntity(Order.UserID, this.CPassport);
                this.rptList.DataSource = BLL.OrderItemManager.GetItemList(OrderID, this.CPassport);
                this.rptList.DataBind();
            }
        }
        #endregion
    }
}
